<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>43. 使用原子组别名优化正则</title>
</head>
<main>
    <a id="li" href="http://www.houdunren.com">后盾人</a>

    <a   href="http://www.hdcms.com">
        hdcms
    </a>
    <a   href="http://www.sina.com.cn">
        hdcms
    </a>
 
</main>

<body>
</body>
<script>
//[{link:'',title:''}]
const main=document.querySelector('body main');
const reg=/<a.*?href=(['"])(?<link>.*?)\1>(?<title>.*?)<\/a>/gi;
// let res=main.innerHTML.match(reg);
// console.log(res);
let links=[];
for (const iterator of main.innerHTML.matchAll(reg)) {
    console.log(iterator);
    links.push(iterator.groups)
}
console.log(links);
</script>

</html>